/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bt;

import com.sun.midp.io.Base64;
import java.io.IOException;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import org.netbeans.microedition.util.SimpleCancellableTask;

/**
 * @author kszyh
 */
public class Midlet extends MIDlet implements CommandListener {

    private boolean midletPaused = false;

    //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
    private List menu;
    private Form Klient;
    private Spacer spacer1;
    private StringItem stringItem;
    private StringItem receivedString;
    private Spacer spacer;
    private TextField toSendField;
    private Alert alert;
    private Form form;
    private ImageItem imageItem;
    private ChoiceGroup choiceGroup1;
    private ChoiceGroup choiceGroup;
    private Command backCommand;
    private Command okCommand;
    private Command backCommand1;
    private Command okCommand1;
    private Command cancelCommand;
    private Command backCommand2;
    private Command okCommand2;
    private Command cancelCommand1;
    private Command screenCommand;
    private SimpleCancellableTask task;
    //</editor-fold>//GEN-END:|fields|0|
    public Receiver rec;
    private MyCustomItem myCustomItem;
    static public Image obrazek;


    /**
     * The Midlet constructor.
     */
    public Midlet() {

display = Display.getDisplay(this);
    }

    //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
    //</editor-fold>//GEN-END:|methods|0|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
    /**
     * Initilizes the application.
     * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
     */
    private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
        // write pre-initialize user code here
//GEN-LINE:|0-initialize|1|0-postInitialize
        // write post-initialize user code here
    }//GEN-BEGIN:|0-initialize|2|
    //</editor-fold>//GEN-END:|0-initialize|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Started point.
     */
    public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
        // write pre-action user code here
        switchDisplayable(null, getMenu());//GEN-LINE:|3-startMIDlet|1|3-postAction
        // write post-action user code here
    }//GEN-BEGIN:|3-startMIDlet|2|
    //</editor-fold>//GEN-END:|3-startMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
     */
    public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction
        // write pre-action user code here
        switchDisplayable(null, getKlient());//GEN-LINE:|4-resumeMIDlet|1|4-postAction
        // write post-action user code here
    }//GEN-BEGIN:|4-resumeMIDlet|2|
    //</editor-fold>//GEN-END:|4-resumeMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
    /**
     * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
     * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
     * @param nextDisplayable the Displayable to be set
     */
    public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
        // write pre-switch user code here
        Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
        if (alert == null) {
            display.setCurrent(nextDisplayable);
        } else {
            display.setCurrent(alert, nextDisplayable);
        }//GEN-END:|5-switchDisplayable|1|5-postSwitch
        // write post-switch user code here
    }//GEN-BEGIN:|5-switchDisplayable|2|
    //</editor-fold>//GEN-END:|5-switchDisplayable|2|
    public void getRec(BluetoothConnection btConnect){
    rec = new Receiver(new BluetoothConnection[] {btConnect}, this,false);

    }
    //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
    /**
     * Called by a system to indicated that a command has been invoked on a particular displayable.
     * @param command the Command that was invoked
     * @param displayable the Displayable where the command was invoked
     */
    public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
        // write pre-action user code here
        if (displayable == Klient) {//GEN-BEGIN:|7-commandAction|1|43-preAction
            if (command == backCommand) {//GEN-END:|7-commandAction|1|43-preAction
                // write pre-action user code here
                switchDisplayable(null, getMenu());//GEN-LINE:|7-commandAction|2|43-postAction
                // write post-action user code here
            } else if (command == okCommand) {//GEN-LINE:|7-commandAction|3|47-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|4|47-postAction
               // wysylanie tekstu
                String txt = getToSendField().getString();
                rec.sendString(txt);

                getToSendField().setString("");

                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|5|80-preAction
        } else if (displayable == alert) {
            if (command == cancelCommand) {//GEN-END:|7-commandAction|5|80-preAction
                // write pre-action user code here
                switchDisplayable(null, getMenu());//GEN-LINE:|7-commandAction|6|80-postAction
                // write post-action user code here
            } else if (command == okCommand1) {//GEN-LINE:|7-commandAction|7|78-preAction
                // write pre-action user code here
                switchDisplayable(null, getForm());//GEN-LINE:|7-commandAction|8|78-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|9|95-preAction
        } else if (displayable == form) {
            if (command == cancelCommand1) {//GEN-END:|7-commandAction|9|95-preAction
                displayImage("c");
//GEN-LINE:|7-commandAction|10|95-postAction
                // write post-action user code here
            } else if (command == okCommand2) {//GEN-LINE:|7-commandAction|11|87-preAction
                // write pre-action user code here
                switchDisplayable(null, getMenu());//GEN-LINE:|7-commandAction|12|87-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|13|24-preAction
        } else if (displayable == menu) {
            if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|13|24-preAction
                // write pre-action user code here
                menuAction();//GEN-LINE:|7-commandAction|14|24-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|15|7-postCommandAction
        }//GEN-END:|7-commandAction|15|7-postCommandAction
        // write post-action user code here
    }//GEN-BEGIN:|7-commandAction|16|
    //</editor-fold>//GEN-END:|7-commandAction|16|



    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: menu ">//GEN-BEGIN:|23-getter|0|23-preInit
    /**
     * Returns an initiliazed instance of menu component.
     * @return the initialized component instance
     */
    public List getMenu() {
        if (menu == null) {//GEN-END:|23-getter|0|23-preInit
            // write pre-init user code here
            menu = new List("list", Choice.IMPLICIT);//GEN-BEGIN:|23-getter|1|23-postInit
            menu.append("Po\u0142\u0105cz", null);
            menu.append("Wyjd\u017A", null);
            menu.append("Image-TEST", null);
            menu.setCommandListener(this);
            menu.setSelectedFlags(new boolean[] { false, false, false });//GEN-END:|23-getter|1|23-postInit

            // write post-init user code here
        }//GEN-BEGIN:|23-getter|2|
        return menu;
    }
    //</editor-fold>//GEN-END:|23-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: menuAction ">//GEN-BEGIN:|23-action|0|23-preAction
    /**
     * Performs an action assigned to the selected list element in the menu component.
     */
    public void menuAction() {//GEN-END:|23-action|0|23-preAction
        // enter pre-action user code here
        String __selectedString = getMenu().getString(getMenu().getSelectedIndex());//GEN-BEGIN:|23-action|1|36-preAction
        if (__selectedString != null) {
            if (__selectedString.equals("Po\u0142\u0105cz")) {//GEN-END:|23-action|1|36-preAction
                new BTClient(this);
//GEN-LINE:|23-action|2|36-postAction
                // write post-action user code here
            } else if (__selectedString.equals("Wyjd\u017A")) {//GEN-LINE:|23-action|3|37-preAction
                // write pre-action user code here
                exitMIDlet();//GEN-LINE:|23-action|4|37-postAction
                // write post-action user code here
            } else if (__selectedString.equals("Image-TEST")) {//GEN-LINE:|23-action|5|81-preAction
                // write pre-action user code here
                switchDisplayable(getAlert(), getMenu());//GEN-LINE:|23-action|6|81-postAction
                // write post-action user code here
            }//GEN-BEGIN:|23-action|7|23-postAction
        }//GEN-END:|23-action|7|23-postAction
        // enter post-action user code here
    }//GEN-BEGIN:|23-action|8|
    //</editor-fold>//GEN-END:|23-action|8|




    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: Klient ">//GEN-BEGIN:|32-getter|0|32-preInit
    /**
     * Returns an initiliazed instance of Klient component.
     * @return the initialized component instance
     */
    public Form getKlient() {
        if (Klient == null) {//GEN-END:|32-getter|0|32-preInit
            // write pre-init user code here
            Klient = new Form("Klient", new Item[] { getSpacer1(), getStringItem(), getSpacer(), getReceivedString(), getToSendField() });//GEN-BEGIN:|32-getter|1|32-postInit
            Klient.addCommand(getBackCommand());
            Klient.addCommand(getOkCommand());
            Klient.setCommandListener(this);//GEN-END:|32-getter|1|32-postInit
            // write post-init user code here
        }//GEN-BEGIN:|32-getter|2|
        return Klient;
    }
    //</editor-fold>//GEN-END:|32-getter|2|





    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: task ">//GEN-BEGIN:|31-getter|0|31-preInit
    /**
     * Returns an initiliazed instance of task component.
     * @return the initialized component instance
     */
    public SimpleCancellableTask getTask() {
        if (task == null) {//GEN-END:|31-getter|0|31-preInit
            // write pre-init user code here
            task = new SimpleCancellableTask();//GEN-BEGIN:|31-getter|1|31-execute
            task.setExecutable(new org.netbeans.microedition.util.Executable() {
                public void execute() throws Exception {//GEN-END:|31-getter|1|31-execute
                    // write task-execution user code here


                }//GEN-BEGIN:|31-getter|2|31-postInit
            });//GEN-END:|31-getter|2|31-postInit
            // write post-init user code here
        }//GEN-BEGIN:|31-getter|3|
        return task;
    }
    //</editor-fold>//GEN-END:|31-getter|3|





    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand ">//GEN-BEGIN:|42-getter|0|42-preInit
    /**
     * Returns an initiliazed instance of backCommand component.
     * @return the initialized component instance
     */
    public Command getBackCommand() {
        if (backCommand == null) {//GEN-END:|42-getter|0|42-preInit
            // write pre-init user code here
            backCommand = new Command("Wr\u00F3\u0107", Command.BACK, 0);//GEN-LINE:|42-getter|1|42-postInit
            // write post-init user code here
        }//GEN-BEGIN:|42-getter|2|
        return backCommand;
    }
    //</editor-fold>//GEN-END:|42-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: spacer1 ">//GEN-BEGIN:|44-getter|0|44-preInit
    /**
     * Returns an initiliazed instance of spacer1 component.
     * @return the initialized component instance
     */
    public Spacer getSpacer1() {
        if (spacer1 == null) {//GEN-END:|44-getter|0|44-preInit
            // write pre-init user code here
            spacer1 = new Spacer(16, 20);//GEN-LINE:|44-getter|1|44-postInit
            // write post-init user code here
        }//GEN-BEGIN:|44-getter|2|
        return spacer1;
    }
    //</editor-fold>//GEN-END:|44-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand ">//GEN-BEGIN:|46-getter|0|46-preInit
    /**
     * Returns an initiliazed instance of okCommand component.
     * @return the initialized component instance
     */
    public Command getOkCommand() {
        if (okCommand == null) {//GEN-END:|46-getter|0|46-preInit
            // write pre-init user code here
            okCommand = new Command("Wy\u015Blij", Command.OK, 0);//GEN-LINE:|46-getter|1|46-postInit
            // write post-init user code here
        }//GEN-BEGIN:|46-getter|2|
        return okCommand;
    }
    //</editor-fold>//GEN-END:|46-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand1 ">//GEN-BEGIN:|49-getter|0|49-preInit
    /**
     * Returns an initiliazed instance of backCommand1 component.
     * @return the initialized component instance
     */
    public Command getBackCommand1() {
        if (backCommand1 == null) {//GEN-END:|49-getter|0|49-preInit
            // write pre-init user code here
            backCommand1 = new Command("Back", Command.BACK, 0);//GEN-LINE:|49-getter|1|49-postInit
            // write post-init user code here
        }//GEN-BEGIN:|49-getter|2|
        return backCommand1;
    }
    //</editor-fold>//GEN-END:|49-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem ">//GEN-BEGIN:|62-getter|0|62-preInit
    /**
     * Returns an initiliazed instance of stringItem component.
     * @return the initialized component instance
     */
    public StringItem getStringItem() {
        if (stringItem == null) {//GEN-END:|62-getter|0|62-preInit
            // write pre-init user code here
            stringItem = new StringItem("Wiadomo\u015B\u0107 przychodz\u0105ca:", "");//GEN-LINE:|62-getter|1|62-postInit
            // write post-init user code here
        }//GEN-BEGIN:|62-getter|2|
        return stringItem;
    }
    //</editor-fold>//GEN-END:|62-getter|2|



    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: toSendField ">//GEN-BEGIN:|64-getter|0|64-preInit
    /**
     * Returns an initiliazed instance of toSendField component.
     * @return the initialized component instance
     */
    public TextField getToSendField() {
        if (toSendField == null) {//GEN-END:|64-getter|0|64-preInit
            // write pre-init user code here
            toSendField = new TextField("Wy\u015Blij:", null, 32, TextField.ANY);//GEN-LINE:|64-getter|1|64-postInit
            // write post-init user code here
        }//GEN-BEGIN:|64-getter|2|
        return toSendField;
    }
    //</editor-fold>//GEN-END:|64-getter|2|



    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: receivedString ">//GEN-BEGIN:|69-getter|0|69-preInit
    /**
     * Returns an initiliazed instance of receivedString component.
     * @return the initialized component instance
     */
    public StringItem getReceivedString() {
        if (receivedString == null) {//GEN-END:|69-getter|0|69-preInit
            // write pre-init user code here
            receivedString = new StringItem("", "cos", Item.PLAIN);//GEN-LINE:|69-getter|1|69-postInit
            // write post-init user code here
        }//GEN-BEGIN:|69-getter|2|
        return receivedString;
    }
    //</editor-fold>//GEN-END:|69-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: spacer ">//GEN-BEGIN:|71-getter|0|71-preInit
    /**
     * Returns an initiliazed instance of spacer component.
     * @return the initialized component instance
     */
    public Spacer getSpacer() {
        if (spacer == null) {//GEN-END:|71-getter|0|71-preInit
            // write pre-init user code here
            spacer = new Spacer(16, 1);//GEN-BEGIN:|71-getter|1|71-postInit
            spacer.setLayout(ImageItem.LAYOUT_DEFAULT | Item.LAYOUT_TOP | Item.LAYOUT_BOTTOM | Item.LAYOUT_VCENTER | ImageItem.LAYOUT_NEWLINE_AFTER);
            spacer.setPreferredSize(-1, 5);//GEN-END:|71-getter|1|71-postInit
            // write post-init user code here
        }//GEN-BEGIN:|71-getter|2|
        return spacer;
    }
    //</editor-fold>//GEN-END:|71-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand2 ">//GEN-BEGIN:|75-getter|0|75-preInit
    /**
     * Returns an initiliazed instance of backCommand2 component.
     * @return the initialized component instance
     */
    public Command getBackCommand2() {
        if (backCommand2 == null) {//GEN-END:|75-getter|0|75-preInit
            // write pre-init user code here
            backCommand2 = new Command("Back", Command.BACK, 0);//GEN-LINE:|75-getter|1|75-postInit
            // write post-init user code here
        }//GEN-BEGIN:|75-getter|2|
        return backCommand2;
    }
    //</editor-fold>//GEN-END:|75-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: alert ">//GEN-BEGIN:|76-getter|0|76-preInit
    /**
     * Returns an initiliazed instance of alert component.
     * @return the initialized component instance
     */
    public Alert getAlert() {
        if (alert == null) {//GEN-END:|76-getter|0|76-preInit
            // write pre-init user code here
            alert = new Alert("Ostrze\u017Cenie", "Otrzymano obrazek. Otworzy\u0107?", null, AlertType.CONFIRMATION);//GEN-BEGIN:|76-getter|1|76-postInit
            alert.addCommand(getOkCommand1());
            alert.addCommand(getCancelCommand());
            alert.setCommandListener(this);
            alert.setTimeout(Alert.FOREVER);//GEN-END:|76-getter|1|76-postInit
            // write post-init user code here
        }//GEN-BEGIN:|76-getter|2|
        return alert;
    }
    //</editor-fold>//GEN-END:|76-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form ">//GEN-BEGIN:|84-getter|0|84-preInit
    /**
     * Returns an initiliazed instance of form component.
     * @return the initialized component instance
     */
    public Form getForm() {
        if (form == null) {//GEN-END:|84-getter|0|84-preInit
            // write pre-init user code here
            form = new Form("Galeria", new Item[] { getImageItem(), getChoiceGroup(), getChoiceGroup1() });//GEN-BEGIN:|84-getter|1|84-postInit
            form.addCommand(getOkCommand2());
            form.addCommand(getCancelCommand1());
            form.setCommandListener(this);//GEN-END:|84-getter|1|84-postInit
            form.append(getMyCustomItem());
            //getMyCustomItem().setLayout(MyCustomItem.LAYOUT_EXPAND);
            // write post-init user code here
        }//GEN-BEGIN:|84-getter|2|
        return form;
    }
    //</editor-fold>//GEN-END:|84-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand1 ">//GEN-BEGIN:|77-getter|0|77-preInit
    /**
     * Returns an initiliazed instance of okCommand1 component.
     * @return the initialized component instance
     */
    public Command getOkCommand1() {
        if (okCommand1 == null) {//GEN-END:|77-getter|0|77-preInit
            // write pre-init user code here
            okCommand1 = new Command("TAK", Command.OK, 0);//GEN-LINE:|77-getter|1|77-postInit
            // write post-init user code here
        }//GEN-BEGIN:|77-getter|2|
        return okCommand1;
    }
    //</editor-fold>//GEN-END:|77-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: cancelCommand ">//GEN-BEGIN:|79-getter|0|79-preInit
    /**
     * Returns an initiliazed instance of cancelCommand component.
     * @return the initialized component instance
     */
    public Command getCancelCommand() {
        if (cancelCommand == null) {//GEN-END:|79-getter|0|79-preInit
            // write pre-init user code here
            cancelCommand = new Command("NIE", Command.CANCEL, 0);//GEN-LINE:|79-getter|1|79-postInit
            // write post-init user code here
        }//GEN-BEGIN:|79-getter|2|
        return cancelCommand;
    }
    //</editor-fold>//GEN-END:|79-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand2 ">//GEN-BEGIN:|86-getter|0|86-preInit
    /**
     * Returns an initiliazed instance of okCommand2 component.
     * @return the initialized component instance
     */
    public Command getOkCommand2() {
        if (okCommand2 == null) {//GEN-END:|86-getter|0|86-preInit
            // write pre-init user code here
            okCommand2 = new Command("Ok", Command.OK, 0);//GEN-LINE:|86-getter|1|86-postInit
            // write post-init user code here
        }//GEN-BEGIN:|86-getter|2|
        return okCommand2;
    }
    //</editor-fold>//GEN-END:|86-getter|2|





    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: imageItem ">//GEN-BEGIN:|93-getter|0|93-preInit
    /**
     * Returns an initiliazed instance of imageItem component.
     * @return the initialized component instance
     */
    public ImageItem getImageItem() {
        if (imageItem == null) {//GEN-END:|93-getter|0|93-preInit
            // write pre-init user code here
            imageItem = new ImageItem("", null, ImageItem.LAYOUT_DEFAULT, "<Brak obrazka>", Item.PLAIN);//GEN-LINE:|93-getter|1|93-postInit
            // write post-init user code here
        }//GEN-BEGIN:|93-getter|2|
        return imageItem;
    }
    //</editor-fold>//GEN-END:|93-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: cancelCommand1 ">//GEN-BEGIN:|94-getter|0|94-preInit
    /**
     * Returns an initiliazed instance of cancelCommand1 component.
     * @return the initialized component instance
     */
    public Command getCancelCommand1() {
        if (cancelCommand1 == null) {//GEN-END:|94-getter|0|94-preInit
            // write pre-init user code here
            cancelCommand1 = new Command("Cancel", Command.CANCEL, 0);//GEN-LINE:|94-getter|1|94-postInit
            // write post-init user code here
        }//GEN-BEGIN:|94-getter|2|
        return cancelCommand1;
    }
    //</editor-fold>//GEN-END:|94-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: screenCommand ">//GEN-BEGIN:|97-getter|0|97-preInit
    /**
     * Returns an initiliazed instance of screenCommand component.
     * @return the initialized component instance
     */
    public Command getScreenCommand() {
        if (screenCommand == null) {//GEN-END:|97-getter|0|97-preInit
            // write pre-init user code here
            screenCommand = new Command("Screen", Command.SCREEN, 0);//GEN-LINE:|97-getter|1|97-postInit
            // write post-init user code here
        }//GEN-BEGIN:|97-getter|2|
        return screenCommand;
    }
    //</editor-fold>//GEN-END:|97-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: choiceGroup ">//GEN-BEGIN:|99-getter|0|99-preInit
    /**
     * Returns an initiliazed instance of choiceGroup component.
     * @return the initialized component instance
     */
    public ChoiceGroup getChoiceGroup() {
        if (choiceGroup == null) {//GEN-END:|99-getter|0|99-preInit
            // write pre-init user code here
            choiceGroup = new ChoiceGroup("", Choice.MULTIPLE);//GEN-LINE:|99-getter|1|99-postInit
            // write post-init user code here
        }//GEN-BEGIN:|99-getter|2|
        return choiceGroup;
    }
    //</editor-fold>//GEN-END:|99-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: choiceGroup1 ">//GEN-BEGIN:|100-getter|0|100-preInit
    /**
     * Returns an initiliazed instance of choiceGroup1 component.
     * @return the initialized component instance
     */
    public ChoiceGroup getChoiceGroup1() {
        if (choiceGroup1 == null) {//GEN-END:|100-getter|0|100-preInit
            // write pre-init user code here
            choiceGroup1 = new ChoiceGroup("choiceGroup1", Choice.MULTIPLE);//GEN-BEGIN:|100-getter|1|100-postInit
            choiceGroup1.setFitPolicy(Choice.TEXT_WRAP_DEFAULT);//GEN-END:|100-getter|1|100-postInit
            // write post-init user code here
        }//GEN-BEGIN:|100-getter|2|
        return choiceGroup1;
    }
    //</editor-fold>//GEN-END:|100-getter|2|
    static int dx;
    public MyCustomItem getMyCustomItem() {
        if (myCustomItem == null) {
            // write pre-init user code here
            myCustomItem = new MyCustomItem();
            // write post-init user code here
        }
        return myCustomItem;
    }

    /**
     * Returns a display instance.
     * @return the display instance.
     */
    public Display getDisplay () {
        return Display.getDisplay(this);
    }

    /**
     * Exits MIDlet.
     */
    public void exitMIDlet() {
        switchDisplayable (null, null);
        destroyApp(true);
        notifyDestroyed();
    }

    /**
     * Called when MIDlet is started.
     * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
     */
    /*public void startApp() {
    if (midletPaused) {
    resumeMIDlet ();
    } else {
    initialize ();
    startMIDlet ();
    }
    midletPaused = false;
    }*/

        Display display;
    Command exit;


        public void startApp () {
            
       
    if (midletPaused) {
    resumeMIDlet ();
    } else {
    initialize ();
    startMIDlet ();
    }
    midletPaused = false;

    }
        

      
    /**
     * Called when MIDlet is paused.
     */
    public void pauseApp() {
        midletPaused = true;
    }

    public void displayImage(String imageString){
//String data = "/9j/4AAQSkZJRgABAQEAYABgAAD/4QAWRXhp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sE7Lvt5G/glXlTnBIB6HAztLDvRRWtCtOhUjVg7OLugPma+srnTb+exvYHguoG2yRP1U/wBQeoI4I5GRVckKMkgD1NFFfrlFKpyX+0ov70n+p71KtKVD2j3se9fCrwfPoGmT6nqVv5WoXuAiOBvihHIB4yrMeSM9AmQCCK9Door8rzHEzxOJnUqb3t8lojwpSc3zPdlTU9Ot9X0y50+7TdBcRlG4BIz3GQRkHkHsQK8R1j4P6/Z3IGmNFqEDdG3LEy8D7wY46k4wT07UUU8FmOIwbbovfddDWjiJ0vhOq8DfC2TRtQt9X1ieJ7iL5o7VFDKjEDBZj3BJ6dwCDXp9FFY4nFVcVU9pVd2TUqyqS5pBRRRXOZhRRRQAUUUUAFFFFABRRRQAUUUUAFeEfEqS5fxtdC4DBERFg3Lj5MZ49RuLc/4UUV14XaR9Bwx/yMV/hf6f8N6NnI0UUV0H6QFfSuhSXMugafJehhdNboZQ67Tu2jOR25oorOv/AAvmvyZ8Vxf/AMuf+3v/AG00KKKK4D4wKKKKACiiigD/2Q==";
 String data = imageString;
        try {
            byte[] imageByteArray = Base64.decode(data);
            Image img = Image.createImage(imageByteArray, 0, (imageByteArray.length)-1);
            getImageItem().setImage(img);
            obrazek = img;
        } catch (Exception ex) {
        }

    }

    public void displayImage(Image img){
    getImageItem().setImage(img);
   }

    public int getWysokosc(){
        return getMenu().getHeight();
    }

    public int getSzerokosc(){
        return getMenu().getWidth();
    }

    /**
     * Called to signal the MIDlet to terminate.
     * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
     */

    public void destroyApp(boolean unconditional) {
    }


    //============================================================================
  class MyCustomItem extends CustomItem{
  public MyCustomItem(){
      super("");
  }


  protected  void keyPressed(int keyCode){
    //write ur code here to do stuff

      switch (keyCode){
          case 48:
              Image i = ImageManipulator.resizeImage(Midlet.obrazek, getSzerokosc(), getWysokosc());
              displayImage(i);
              break;
          case 49:
              Image i1 = ImageManipulator.Rotate(obrazek);
              displayImage(i1);
              obrazek = i1;
              break;
          case 52: // 4
              if(dx >= 0){
              Image i2 = ImageManipulator.Fragment(obrazek, dx, 0, dx+getSzerokosc(), obrazek.getHeight());
              dx -= 10;
              displayImage(i2);
              }
              break;
          case 54: // 6
              if((dx + getSzerokosc()) <= obrazek.getWidth()){
              Image i2 = ImageManipulator.Fragment(obrazek, dx, 0, dx+getSzerokosc(), obrazek.getHeight());
              dx += 10;
              displayImage(i2);
              }
              break;
          case 53: // 5
              displayImage(obrazek);
              dx = 0;
              break;
      }
  }

    protected int getMinContentWidth() {
    return 1;
    }

    protected int getMinContentHeight() {
    return 1;
    }

    protected int getPrefContentWidth(int height) {
    return 1;
    }

    protected int getPrefContentHeight(int width) {
    return 1;
    }

    protected void paint(Graphics g, int w, int h) {

    }
}
}

